package com.xiaoniu.forum.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoniu.forum.entity.CommunityTopicEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiaoniu.forum.entity.vo.AppCommunityTopTopicVo;
import com.xiaoniu.forum.entity.vo.AppCommunityTopicVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 话题表
 * 
 * @author xiaoniu
 * @email 55333@qq.com
 * @date 2021-03-23 15:07:41
 */
@Mapper
public interface CommunityTopicDao extends BaseMapper<CommunityTopicEntity> {

    @Select("SELECT t.id,t.title,s.`notice`,s.`top` " +
            "FROM `t_community_topic` t ," +
            "`t_community_topic_status` s " +
            "where " +
            "t.community_id = #{id} AND " +
            "t.id = s.`threads_id` AND " +
            "t.`status` = '1' AND " +
            "t.`pass` = '1' AND (s.notice = '1' " +
            "OR " +
            "s.top = '1' ) " +
            "ORDER BY s.`notice` DESC")
    List<AppCommunityTopTopicVo> getTopicTops(String id);

    /**
     *  查询热门话题
     */
    List<CommunityTopicEntity> queryHotTopics(Page page);
	
}
